package com.example.weatherpredict.ui;

import android.content.Context;
import android.content.Intent;

import androidx.fragment.app.Fragment;

import com.example.weatherpredict.R;
import com.example.weatherpredict.entity.Weather;
import com.example.weatherpredict.entity.WeatherItem;
import com.example.weatherpredict.base.SingleFragmentActivity;

public class WeatherDetailActivity extends SingleFragmentActivity {
    public static final String EXTRA_WEATHER_ITEM = "com.example.weather.weatherItem";

    @Override
    protected Fragment createFragment() {
        Weather.DailyBean weatherItem = ( Weather.DailyBean) getIntent().getSerializableExtra(EXTRA_WEATHER_ITEM);
        return WeatherDetailFragment.newInstance(weatherItem);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_detail;
    }

    @Override
    protected int getFragmentId() {
        return R.id.detail_container;
    }

    public static Intent newIntent(Context packageContext,  Weather.DailyBean weatherItem) {
        Intent intent = new Intent(packageContext, WeatherDetailActivity.class);
        intent.putExtra(EXTRA_WEATHER_ITEM, weatherItem);
        return intent;
    }
}
